home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 117
/
FreelogNo117-OctobreNovembre2013.iso
/
Programmation
/
jedit
/
jedit5.1.0install.exe
/
{app}
/
macros
/
Files
/
Insert_Selection.bsh
< prev
next >
Wrap
Text File
|
2013-07-28
|
1KB
|
54 lines
/*
* Insert_Selection.bsh - Inserts the contents of the
* current selection (assuming it's the path to a file)
* into the current buffer -- replacing the selected
* text. Text must be selected and it must not span
* multiple lines.
*
* Copyright (C) 2004 Ollie Rutherfurd <oliver@jedit.org>
*
* $Id: Insert_Selection.bsh 22845 2013-03-16 08:28:12Z thomasmey $
*/
insertSelected(View view, String path){
// read into temporary buffer
Buffer b = jEdit.openTemporary(view,null,path,false);
try{
if(b == null)
return;
while(!b.isLoaded())
VFSManager.waitForRequests();
String text = b.getText(0,b.getLength());
view.getTextArea().setSelectedText(text);
}finally{
if(b != null)
jEdit._closeBuffer(null, b);
}
}
if(buffer.isReadOnly()){
Toolkit.getDefaultToolkit().beep();
}
else{
String selected = view.getTextArea().getSelectedText();
if(selected == null || selected.indexOf('\n') != -1)
Toolkit.getDefaultToolkit().beep();
else
insertSelected(view,selected);
}
/*
<listitem>
<para><filename>Insert_Selection.bsh</filename></para>
<abstract><para>Assumes the current selection is
file path and tries replaces the selection with the
contents of the file. Does nothing if no text is
selected or the selection spans multiple lines.
</para></abstract>
</listitem>
*/